let form = layui.form
console.log(form);
form.verify({
    pwd:[/^\S{6,12}$/, "密码必须是6～12位"],
    same: function (val) {
        if ($(".newpwd").val() !== val) return "两次密码不一致";
        //return的值是验证不通过时的提示
      },
    unSame:function(val){
        if($(".oldpwd").val() === val) return '你改了个寂寞！'
    }
})

//修改密码
console.log($('.change'));
$('#changePwd').on('submit',function(e){
    e.preventDefault()
    let data = $(this).serialize()
    $.ajax({
        type:'POST',
        url:'/my/user/updatepwd',
        data:data,
        success:function(res){
            layer.msg(res.message)
            $('#changePwd')[0].reset()
            localStorage.removeItem("token"); //清除缓存
            window.parent.location.href = '../login.html'; //跳转页面
        }
    })
})